package com.kikcn.demo.services;

import com.kikcn.demo.dao.UserRepository;
import com.kikcn.demo.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * User: wlai
 * Date: 4/9/15
 * Time: 16:18 PM
 */
@Service
@Transactional
public class UserService {
    @Autowired
    private UserRepository userRepository;

    public User findUserByNameAndPassword(String name, String password) {
        return userRepository.findUserByNameAndPassword(name,password);
    }

    public User findByName(String name) {
        return userRepository.findByName(name);
    }

    @Transactional(readOnly = true)
    public Page<User> list(Pageable pageable){
        return  userRepository.findAll(pageable);
    }
}
